package com.magic.gre.mvp.presenter;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.base.BaseObjectModel;
import com.magic.gre.mvp.contract.RegisterContract;
import com.magic.gre.mvp.model.RegisterModelImpl;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

/**
 * Author: Lmoumou
 * Date: 2019-01-10 15:28
 * 文件名: RegisterpresenterImpl
 * 描述:
 */
public class RegisterPresenterImpl extends BasePresenterImpl<RegisterContract.View, RegisterContract.Model>
        implements RegisterContract.Presenter {
    public RegisterPresenterImpl(RegisterContract.View view) {
        super(view);
    }

    @Override
    protected RegisterContract.Model creatModel() {
        return new RegisterModelImpl();
    }

    @Override
    public void pSmsCode(String phone,int type) {
        mModel.mSmsCode(new CommonObserver<BaseObjectModel<String>>(new TypeToken<BaseObjectModel<String>>(){}.getType()) {
            @Override
            protected void onSuccess(BaseObjectModel<String> stringBaseObjectModel) {
                mView.vSmsCode(stringBaseObjectModel.body);

            }

            @Override
            public void onError(int status, String msg) {
                mView.doPrompt(msg);
                mView.hideLoadDialog();
            }
        },phone,type);
    }
}
